<!-- SVG封装组件 确保SVG图标文件本身没有固定颜色值,如果有颜色，就无法自定义颜色 -->
<template>
    <svg
        class="svg-icon"
        :class="className"
        :style="{
            width: size,
            height: size,
            color: color,
        }"
        aria-hidden="true"
    >
        <use :xlink:href="iconName" />
    </svg>
</template>

<script>
export default {
    name: "SvgIcon",
    props: {
        iconClass: {
            type: String,
            required: true,
        },
        className: {
            type: String,
            default: "",
        },
        size: {
            type: String | Number,
            default: 16,
        },
        color: {
            type: String,
            default: "currentColor",
        },
    },
    computed: {
        iconName() {
            return `#icon-${this.iconClass}`
        },
    },
}
</script>

<style scoped>
.svg-icon {
    vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
}
</style>
